Ton van Loon
I want to evaluate 2 custom-fields (calendar-type, no-subfields) against the current date in an {if}-statement, but I can't seem to get the code right. Who can help me?
Environment:
- J4.0.3 / Articles Anywhere 11.0 PRO
- Custom fields: 'first-date', 'last-date', both calendar-type, not a subfield.
-test runs: when editing article > saving > preview
Code{article}
<p><b>INPUT:</b></p>
<p> today is: 10-11-2021 ( 10 november 2021)</p>
<p>first-date is: [first-date]</p>
<p>last-date is: [last-date]</p>
<p>Status-value: [status:value]</p>
{if status='0'}
{article-nested id="[id]"}
<hr/>
<p><b>OUTPUT:</b></p>
{if first-date > date('today') && last-date > date('today') }BOTH IN FUTURE {/if}
{if first-date < date('today') && last-date > date('today') }IN BETWEEN {/if}
{if first-date < date('today') && last-date < date('today') }BOTH IN PAST {/if}
{/article-nested}
{/if}
{/article}
TEST RESULTS
Case 1. Expected outcome: both in future
today is: 10-11-2021 ( 10 november 2021 ) (Confirmed in Joomla as correct date when making new article)
first-date= 15-12-2021
last-date= 31-12-2021
Outcome: Both in future as expected
https://imgur.com/Q007Rlg
Case 2. Expected outcome: in between
today is: 10-11-2021 ( 10 november 2021 )
first-date= 15-08-2021
last-date= 31-12-2021
But Outcome: Both in future NOT as expected
https://imgur.com/jdQgJ7g
Case 3. Expected outcome: both in past
today is: 10-11-2021 ( 10 november 2021 )
first-date= 15-08-2021
last-date= 31-08-2021
But Outcome: Both in future NOT as expected
https://imgur.com/DovNrCO